import * as Types from 'containers/ActionTypes';

export default function (state = {}, action) {
  switch (action.type) {
  case Types.MY.SESSION.LOGIN_SUCCESS:
    return Object.assign({}, state, {
      hasLoggedIn: true,
      profile: action.user,
    });
  case Types.MY.SESSION.TOKEN_SUCCESS:
    return Object.assign({}, state, {
      token: action.token,
    });
  case Types.MY.SESSION.LOGOUT_SUCCESS:
    return Object.assign({}, state, {
      profile: undefined,
      token: undefined,
      hasLoggedIn: false,
    });
  default:
    return state;
  }
}
